window.onload = function() {
	var attrType = document.getElementById('attrtype');
	var attrArr = attrType.value.split(';');
	if(document.getElementById('attrway').value !== '') {
		var attrWay = document.getElementById('attrway').value.split('|');
		var ddRe = document.getElementById('text').getElementsByTagName('dd')[5];
		for(var i=0;i<attrArr.length;i++) {
		    var attrName = attrArr[i].substr(0,attrArr[i].indexOf(':'));
		    var attrPrototype = attrName;
		    if(attrName.length == 2) {
		        attrName = attrName.charAt(0) + '　　' + attrName.charAt(1)+'：';
		    } else if(attrName.length == 3) {
		        attrName = attrName.charAt(0) + ' ' + attrName.charAt(1) + ' ' + attrName.charAt(2)+'：';
		    }
		    var attrValueArr = attrArr[i].substr(attrArr[i].indexOf(':')+1).split('|');                   
		    var dd = document.createElement('dd');
		    var name = document.createTextNode(attrName);
		    dd.className = 'temp';
		    dd.appendChild(name);
		    for(var j=0;j<attrValueArr.length;j++) {                   
		        var text = document.createTextNode(attrValueArr[j]+' ');   
		        if(BrowserDetect.browser == 'Internet Explorer' && BrowserDetect.version <= 7) {
		        	var input = document.createElement('<input name="attr['+attrPrototype+'][]" />');
		        } else {
		           var input = document.createElement('input');
		           input.name = 'attr['+attrPrototype+'][]';  
		        }
		        if(attrWay[i] == 0) {
		        	input.type = 'radio';	        	
		        } else if(attrWay[i] == 1) {
		        	input.type = 'checkbox';
		        }
		        input.value = attrValueArr[j];     //input的value必须在创建type之后才能赋值，否则ie浏览器会不兼容！
		        dd.appendChild(input);
		        dd.appendChild(text);
		    }
		    ddRe.parentNode.insertBefore(dd,ddRe);
		    if(dd.children[0].type == 'radio') dd.children[0].checked = true;
		} 
	}	
	
	//评论列表优先选择
	if(location.href.indexOf('#commend') > 0) {
		for(var i=1;i<5;i++) {
	        document.getElementById('bn'+i).style.backgroundPosition = 'right';
	        document.getElementById('bn'+i).style.color = '#333';
	        document.getElementById('c'+i).style.display = 'none';      
        }
        document.getElementById('bn2').style.backgroundPosition = 'left';
    document.getElementById('bn2').style.color = '#fff';
    document.getElementById('c2').style.display = 'block';    
	}
	
	
	
	//ajax评论分页
	var id = document.getElementById('aid');
	var page = document.getElementById('page');
	var currentPage = document.getElementById('currentPage');
	var commendContent = document.getElementById('content');
	var pageSize = 1;
	var bothNum = 2;
	currentPage.value = 1;
	ajax({
		'url':'?a=details&m=ajaxGetPagenum',
        'async':true,
        'method':'post',
        'data':{
            'id':id.value
        },
        'success':function(num) {
        	var pageNum = Math.ceil(parseInt(num) / pageSize);

        	if((parseInt(currentPage.value) - bothNum) > 1) {
                page.innerHTML += ' <a title="1" href="###" onclick="changePage(this)">1</a>... ';
            }
            
            for(var i=bothNum;i>=1;i--) {
	            var pagec1 = '';
	            var pageList = '';
	            pagec1 = parseInt(currentPage.value) - i;
	            //防止出现负数页码或者页码0
	            if(pagec1 < 1) continue;
	            page.innerHTML += '<a title="'+pagec1+'" href="###" onclick="changePage(this)">'+pagec1+'</a>';
            }
            
            page.innerHTML += '<span class="me">'+parseInt(currentPage.value)+'</span>';
            
            for(var i=1;i<=bothNum;i++) {
	            pagec2 = parseInt(currentPage.value) + i;
	            if(pagec2 > pageNum) break;
	            page.innerHTML += '<a title="'+pagec2+'" href="###" onclick="changePage(this)">'+pagec2+'</a>';
            }
            if((pageNum - (parseInt(currentPage.value)) > bothNum)) {
                page.innerHTML += ' ...<a href="###" title="'+pageNum+'" onclick="changePage(this);">'+pageNum+'</a> ';
            }
            
            page.innerHTML += '<span class="disabled">上一页</span>';
            
            if(pageNum != 1) {
            	page.innerHTML += '<a href="###" onclick="getNextOrPrev(1);">下一页</a>';
            } else {
            	page.innerHTML += '<span class="disabled">下一页</span>';
            }
            
            ajax({
            	'url':'?a=details&m=ajaxGetCommend',
		        'async':true,
		        'method':'post',
		        'data':{
		            'id':id.value,
		            'limit':'0,'+pageSize
		        },
		        'success':function(text) {
		        	var commends = JSON.parse(text);
		        	for(var i=0;i<commends.length;i++) {
		        		var content = '<div class="commend_left">';
		        		content += '<p>'+commends[i].user+'</p>';
		        		content += '<p class="star">';
		        		switch(parseInt(commends[i].star)) {
		        			case 5:
			        			content += '<span class="star">★★★★★</span>';
			        			break;
		        			case 4:
		        			    content += '<span class="star">★★★★</span>';
                                break;
                            case 3:
                                content += '<span class="star">★★★</span>';
                                break;
                            case 2:
                                content += '<span class="star">★★</span>';
                                break;
                            case 1:
                                content += '<span class="star">★</span>';
                                break;
                            default:
		        		}
		        		content += '</p>';
		        		content += '</div>';
		        		content += '<div class="commend_right">';
		        		content += '<p><em>'+commends[i].date+'</em>'+commends[i].content+'</p>';
		        		content += '<p class="attr">'+commends[i].attr+'</p>';
		        		if(commends[i].re_content != '') {
		        		    content += '<p style="color:red;">商家回复：'+commends[i].re_content+'</p>'
		        		}
		        		content += '</div>';
		        		commendContent.innerHTML += content;
	        	    }
	        	    
		        }
            });
        }
	});
	
	//ajax成交记录分页
    var page2 = document.getElementById('page2');
    var currentPage2 = document.getElementById('currentPage2');
    var recordContent = document.getElementById('recordContent');
    var pageSize2 = 1;
    var bothNum2 = 2;
    currentPage2.value = 1;

    ajax({
        'url':'?a=details&m=ajaxGetRecordNum',
        'async':true,
        'method':'post',
        'data':{
            'id':id.value
        },
        'success':function(num) {
            var pageNum = Math.ceil(parseInt(num) / pageSize2);
            
            if((parseInt(currentPage2.value) - bothNum) > 1) {
                page2.innerHTML += ' <a title="1" href="###" onclick="changePage2(this)">1</a>... ';
            }
            
            for(var i=bothNum2;i>=1;i--) {
                var pagec1 = '';
                var pageList = '';
                pagec1 = parseInt(currentPage2.value) - i;
                //防止出现负数页码或者页码0
                if(pagec1 < 1) continue;
                page2.innerHTML += '<a title="'+pagec1+'" href="###" onclick="changePage2(this)">'+pagec1+'</a>';
            }
            
            page2.innerHTML += '<span class="me">'+parseInt(currentPage2.value)+'</span>';
            
            for(var i=1;i<=bothNum2;i++) {
                pagec2 = parseInt(currentPage2.value) + i;
                if(pagec2 > pageNum) break;
                page2.innerHTML += '<a title="'+pagec2+'" href="###" onclick="changePage2(this)">'+pagec2+'</a>';
            }
            if((pageNum - (parseInt(currentPage2.value)) > bothNum2)) {
                page2.innerHTML += ' ...<a href="###" title="'+pageNum+'" onclick="changePage2(this);">'+pageNum+'</a> ';
            }
            
            page2.innerHTML += '<span class="disabled">上一页</span>';
            
            if(pageNum != 1) {
                page2.innerHTML += '<a href="###" onclick="getNextOrPrev2(1);">下一页</a>';
            } else {
                page2.innerHTML += '<span class="disabled">下一页</span>';
            }
            
            ajax({
                'url':'?a=details&m=ajaxGetRecord',
                'async':true,
                'method':'post',
                'data':{
                    'id':id.value,
                    'limit':'0,'+pageSize2
                },
                'success':function(text) {
                    var records = JSON.parse(text);
                    recordContent.innerHTML = '<tr><th>购买者</th><th>商品名称</th><th>购买属性</th><th>购买数量</th><th>购买价格</th><th>成交时间</th></tr>'
                    for(var i=0;i<records.length;i++) {
                    	var content = '<tr>';
                    	content += '<td>'+records[i].user+'</td>';
                    	content += '<td>'+records[i].name+'</td>';
                    	content += '<td>'+records[i].attr+'</td>';
                    	content += '<td>'+records[i].num+'</td>';
                    	content += '<td>'+records[i].price+'</td>';
                    	content += '<td>'+records[i].date+'</td>';
                    	content += '</tr>';
                    	recordContent.innerHTML += content; 
                    }
                    
                }
            });
        }
    });
				
}

function changePage(obj) {
	//ajax评论分页
    var id = document.getElementById('aid');
    var page = document.getElementById('page');
    var currentPage = document.getElementById('currentPage');
    var commendContent = document.getElementById('content');
    var bothNum = 2;
    var pageSize = 1;
    page.innerHTML = '';
    currentPage.value = parseInt(obj.title);
    ajax({
        'url':'?a=details&m=ajaxGetPagenum',
        'async':true,
        'method':'post',
        'data':{
            'id':id.value
        },
        'success':function(num) {
        	var pageNum = Math.ceil(parseInt(num) / pageSize);
        	
        	if((parseInt(currentPage.value) - bothNum) > 1) {
                page.innerHTML += ' <a title="1" href="###" onclick="changePage(this)">1</a>... ';
            }
            
            for(var i=bothNum;i>=1;i--) {
                var pagec1 = '';
                var pageList = '';
                pagec1 = parseInt(currentPage.value) - i;
                //防止出现负数页码或者页码0
                if(pagec1 < 1) continue;
                page.innerHTML += '<a title="'+pagec1+'" href="###" onclick="changePage(this)">'+pagec1+'</a>';
            }
            
            page.innerHTML += '<span class="me">'+parseInt(currentPage.value)+'</span>';
            
            for(var i=1;i<=bothNum;i++) {
                pagec2 = parseInt(currentPage.value) + i;
                if(pagec2 > pageNum) break;
                page.innerHTML += '<a title="'+pagec2+'" href="###" onclick="changePage(this)">'+pagec2+'</a>';
            }
            
            if((pageNum - (parseInt(currentPage.value)) > bothNum)) {
                page.innerHTML += ' ...<a href="###" title="'+pageNum+'" onclick="changePage(this);">'+pageNum+'</a> ';
            }
            
            if(parseInt(currentPage.value) == 1) {
               page.innerHTML += '<span class="disabled">上一页</span>';
            } else {
               page.innerHTML += '<a href="###" onclick="getNextOrPrev(0);">上一页</a>';
            }
            
            if(num == parseInt(currentPage.value)) {
               page.innerHTML += '<span class="disabled">下一页</span>';
            } else {
               page.innerHTML += '<a href="###" onclick="getNextOrPrev(1);">下一页</a>';
            }
            
            ajax({
                'url':'?a=details&m=ajaxGetCommend',
                'async':true,
                'method':'post',
                'data':{
                    'id':id.value,
                    'limit':(currentPage.value-1)+','+pageSize
                },
                'success':function(text) {
                    var commends = JSON.parse(text);
                    for(var i=0;i<commends.length;i++) {
                        var content = '<div class="commend_left">';
                        content += '<p>'+commends[i].user+'</p>';
                        content += '<p class="star">';
                        switch(parseInt(commends[i].star)) {
                            case 5:
                                content += '<span class="star">★★★★★</span>';
                                break;
                            case 4:
                                content += '<span class="star">★★★★</span>';
                                break;
                            case 3:
                                content += '<span class="star">★★★</span>';
                                break;
                            case 2:
                                content += '<span class="star">★★</span>';
                                break;
                            case 1:
                                content += '<span class="star">★</span>';
                                break;
                            default:
                        }
                        content += '</p>';
                        content += '</div>';
                        content += '<div class="commend_right">';
                        content += '<p><em>'+commends[i].date+'</em>'+commends[i].content+'</p>';
                        content += '<p class="attr">'+commends[i].attr+'</p>';
                        if(commends[i].re_content != '') {
                            content += '<p style="color:red;">商家回复：'+commends[i].re_content+'</p>'
                        }
                        content += '</div>';
                    }
                    commendContent.innerHTML = content;
                }
            });
        }
    });
    
}


function getNextOrPrev(flag) {
	//ajax评论分页
    var id = document.getElementById('aid');
    var page = document.getElementById('page');
    var currentPage = document.getElementById('currentPage');
    var commendContent = document.getElementById('content');
    var bothNum = 2;
    var pageSize = 1;
    page.innerHTML = '';
    var num = flag == 1 ? 1 : -1;
    currentPage.value = parseInt(currentPage.value) + num;
    ajax({
        'url':'?a=details&m=ajaxGetPagenum',
        'async':true,
        'method':'post',
        'data':{
            'id':id.value
        },
        'success':function(num) {
            var pageNum = Math.ceil(parseInt(num) / pageSize);
            
            if((parseInt(currentPage.value) - bothNum) > 1) {
                page.innerHTML += ' <a title="1" href="###" onclick="changePage(this)">1</a>... ';
            }
            
            for(var i=bothNum;i>=1;i--) {
                var pagec1 = '';
                var pageList = '';
                pagec1 = parseInt(currentPage.value) - i;
                //防止出现负数页码或者页码0
                if(pagec1 < 1) continue;
                page.innerHTML += '<a title="'+pagec1+'" href="###" onclick="changePage(this)">'+pagec1+'</a>';
            }
            
            page.innerHTML += '<span class="me">'+parseInt(currentPage.value)+'</span>';
            
            for(var i=1;i<=bothNum;i++) {
                pagec2 = parseInt(currentPage.value) + i;
                if(pagec2 > pageNum) break;
                page.innerHTML += '<a title="'+pagec2+'" href="###" onclick="changePage(this)">'+pagec2+'</a>';
            }
            
            if((pageNum - (parseInt(currentPage.value)) > bothNum)) {
                page.innerHTML += ' ...<a href="###" title="'+pageNum+'" onclick="changePage(this);">'+pageNum+'</a> ';
            }
            
            if(parseInt(currentPage.value) == 1) {
               page.innerHTML += '<span class="disabled">上一页</span>';
            } else {
               page.innerHTML += '<a href="###" onclick="getNextOrPrev(0);">上一页</a>';
            }
            
            if(num == parseInt(currentPage.value)) {
               page.innerHTML += '<span class="disabled">下一页</span>';
            } else {
               page.innerHTML += '<a href="###" onclick="getNextOrPrev(1);">下一页</a>';
            }
            
            ajax({
                'url':'?a=details&m=ajaxGetCommend',
                'async':true,
                'method':'post',
                'data':{
                    'id':id.value,
                    'limit':(currentPage.value-1)+','+pageSize
                },
                'success':function(text) {
                    var commends = JSON.parse(text);
                    for(var i=0;i<commends.length;i++) {
                        var content = '<div class="commend_left">';
                        content += '<p>'+commends[i].user+'</p>';
                        content += '<p class="star">';
                        switch(parseInt(commends[i].star)) {
                            case 5:
                                content += '<span class="star">★★★★★</span>';
                                break;
                            case 4:
                                content += '<span class="star">★★★★</span>';
                                break;
                            case 3:
                                content += '<span class="star">★★★</span>';
                                break;
                            case 2:
                                content += '<span class="star">★★</span>';
                                break;
                            case 1:
                                content += '<span class="star">★</span>';
                                break;
                            default:
                        }
                        content += '</p>';
                        content += '</div>';
                        content += '<div class="commend_right">';
                        content += '<p><em>'+commends[i].date+'</em>'+commends[i].content+'</p>';
                        content += '<p class="attr">'+commends[i].attr+'</p>';
                        if(commends[i].re_content != '') {
                            content += '<p style="color:red;">商家回复：'+commends[i].re_content+'</p>'
                        }
                        content += '</div>';
                    }
                    commendContent.innerHTML = content;
                }
            });
        }
    });
}


function changePage2(obj) {
	//ajax成交记录分页
	var id = document.getElementById('aid');
    var page2 = document.getElementById('page2');
    var currentPage2 = document.getElementById('currentPage2');
    var recordContent = document.getElementById('recordContent');
    var pageSize2 = 1;
    var bothNum2 = 2;
    page2.innerHTML = '';
    currentPage2.value = obj.title ;
    ajax({        'url':'?a=details&m=ajaxGetRecordNum',
        'async':true,
        'method':'post',
        'data':{
            'id':id.value
        },
        'success':function(num) {
            var pageNum = Math.ceil(parseInt(num) / pageSize2);
            
            if((parseInt(currentPage2.value) - bothNum2) > 1) {
                page2.innerHTML += ' <a title="1" href="###" onclick="changePage2(this)">1</a>... ';
            }    
            
            for(var i=bothNum2;i>=1;i--) {
                var pagec1 = '';
                var pageList = '';
                pagec1 = parseInt(currentPage2.value) - i;
                //防止出现负数页码或者页码0
                if(pagec1 < 1) continue;
                page2.innerHTML += '<a title="'+pagec1+'" href="###" onclick="changePage2(this)">'+pagec1+'</a>';
            }
            
            page2.innerHTML += '<span class="me">'+parseInt(currentPage2.value)+'</span>';
            
            for(var i=1;i<=bothNum2;i++) {
                pagec2 = parseInt(currentPage2.value) + i;
                if(pagec2 > pageNum) break;
                page2.innerHTML += '<a title="'+pagec2+'" href="###" onclick="changePage2(this)">'+pagec2+'</a>';
            }
            if((pageNum - (parseInt(currentPage2.value)) > bothNum2)) {
                page2.innerHTML += ' ...<a href="###" title="'+pageNum+'" onclick="changePage2(this);">'+pageNum+'</a> ';
            }
            
            if(parseInt(currentPage2.value) == 1) {
               page2.innerHTML += '<span class="disabled">上一页</span>';
            } else {
               page2.innerHTML += '<a href="###" onclick="getNextOrPrev2(0);">上一页</a>';
            }
            
            if(num == parseInt(currentPage2.value)) {
               page2.innerHTML += '<span class="disabled">下一页</span>';
            } else {
               page2.innerHTML += '<a href="###" onclick="getNextOrPrev2(1);">下一页</a>';
            }
            
            ajax({
                'url':'?a=details&m=ajaxGetRecord',
                'async':true,
                'method':'post',
                'data':{
                    'id':id.value,
                    'limit':(currentPage2.value-1)+','+pageSize2
                },
                'success':function(text) {
                    var records = JSON.parse(text);
                    recordContent.innerHTML = '<tr><th>购买者</th><th>商品名称</th><th>购买属性</th><th>购买数量</th><th>购买价格</th><th>成交时间</th></tr>'
                    for(var i=0;i<records.length;i++) {
                        var content = '<tr>';
                        content += '<td>'+records[i].user+'</td>';
                        content += '<td>'+records[i].name+'</td>';
                        content += '<td>'+records[i].attr+'</td>';
                        content += '<td>'+records[i].num+'</td>';
                        content += '<td>'+records[i].price+'</td>';
                        content += '<td>'+records[i].date+'</td>';
                        content += '</tr>';
                        recordContent.innerHTML += content; 
                    }
                    
                }
            });
        }
    });
}

function getNextOrPrev2(flag) {
	//ajax成交记录分页
    var id = document.getElementById('aid');
    var page2 = document.getElementById('page2');
    var currentPage2 = document.getElementById('currentPage2');
    var recordContent = document.getElementById('recordContent');
    var pageSize2 = 1;
    var bothNum2 = 2;
    page2.innerHTML = '';
	var num = flag == 1 ? 1 : -1;
    currentPage2.value = parseInt(currentPage2.value) + num;
     ajax({
        'url':'?a=details&m=ajaxGetRecordNum',
        'async':true,
        'method':'post',
        'data':{
            'id':id.value
        },
        'success':function(num) {
            var pageNum = Math.ceil(parseInt(num) / pageSize2);
            
            if((parseInt(currentPage2.value) - bothNum2) > 1) {
                page2.innerHTML += ' <a title="1" href="###" onclick="changePage2(this)">1</a>... ';
            }    
            
            for(var i=bothNum2;i>=1;i--) {
                var pagec1 = '';
                var pageList = '';
                pagec1 = parseInt(currentPage2.value) - i;
                //防止出现负数页码或者页码0
                if(pagec1 < 1) continue;
                page2.innerHTML += '<a title="'+pagec1+'" href="###" onclick="changePage2(this)">'+pagec1+'</a>';
            }
            
            page2.innerHTML += '<span class="me">'+parseInt(currentPage2.value)+'</span>';
            
            for(var i=1;i<=bothNum2;i++) {
                pagec2 = parseInt(currentPage2.value) + i;
                if(pagec2 > pageNum) break;
                page2.innerHTML += '<a title="'+pagec2+'" href="###" onclick="changePage2(this)">'+pagec2+'</a>';
            }
            
            if((pageNum - (parseInt(currentPage2.value)) > bothNum2)) {
                page2.innerHTML += ' ...<a href="###" title="'+pageNum+'" onclick="changePage2(this);">'+pageNum+'</a> ';
            }
            
            if(parseInt(currentPage2.value) == 1) {
               page2.innerHTML += '<span class="disabled">上一页</span>';
            } else {
               page2.innerHTML += '<a href="###" onclick="getNextOrPrev2(0);">上一页</a>';
            }
            
            if(num == parseInt(currentPage2.value)) {
               page2.innerHTML += '<span class="disabled">下一页</span>';
            } else {
               page2.innerHTML += '<a href="###" onclick="getNextOrPrev2(1);">下一页</a>';
            }
            
            ajax({
                'url':'?a=details&m=ajaxGetRecord',
                'async':true,
                'method':'post',
                'data':{
                    'id':id.value,
                    'limit':(currentPage2.value-1)+','+pageSize2
                },
                'success':function(text) {
                    var records = JSON.parse(text);
                    recordContent.innerHTML = '<tr><th>购买者</th><th>商品名称</th><th>购买属性</th><th>购买数量</th><th>购买价格</th><th>成交时间</th></tr>'
                    for(var i=0;i<records.length;i++) {
                        var content = '<tr>';
                        content += '<td>'+records[i].user+'</td>';
                        content += '<td>'+records[i].name+'</td>';
                        content += '<td>'+records[i].attr+'</td>';
                        content += '<td>'+records[i].num+'</td>';
                        content += '<td>'+records[i].price+'</td>';
                        content += '<td>'+records[i].date+'</td>';
                        content += '</tr>';
                        recordContent.innerHTML += content; 
                    }
                    
                }
            });
        }
    });
}

function noMore(obj) {
	var aid = document.getElementById('aid').value;
	var num = obj.value;
	if((num == 0 && num != '') || isNaN(num)) {
		obj.value = 1;
		return;
	}
	var warning = document.getElementById('warning');
	var sub = document.getElementById('sub');
	warning.style.display = 'none';
	sub.disabled = false;
	sub.style.background = 'url(view/default/images/buy.gif) no-repeat';
	ajax({
		'url':'?a=details&m=isNoMore',
		'async':true,
		'method':'post',
		'data':{
			'num':num,
			'aid':aid
		},
		'success':function(text) {
			if(text == 1) {
				warning.style.display = 'block';
				sub.disabled = true;
				sub.style.background= 'url(view/default/images/buy2.jpg) no-repeat' ;
			}
		}
	});
}

function ajaxBuy() {
	var n = document.getElementById('n');
	var id = document.buy.id;
	var name = document.buy.name;
	var sn = document.buy.sn;
	var price_sale = document.buy.price_sale;
	var prev = document.buy.prev;
	var weight = document.buy.weight;
	var nav = document.buy.nav;
	var thumbnail_small = document.buy.thumbnail_small;
	var input = document.getElementsByTagName('input');   
    var t = [];      //存储所有商品属性节点
    var t1 = [];     //存储商品属性节点的一维数组中的下标
    var t2 = [];    //存储商品属性节点的对应的value
    var tips = document.getElementById('tips');
    tips.style.display = 'none';
    for(var i=0;i<input.length;i++) {       
       if(input[i].name.indexOf('[]') != -1) {
           t.push(input[i]);
       }
    }
    for(var i=0;i<t.length;i++) {
       if(t[i].checked && t[i].type == 'radio') {
         var a = t[i].name.substring(t[i].name.indexOf('[')+1,t[i].name.indexOf(']'));
         t1.push(a);
         t2.push(t[i].value);
       } else if(t[i].checked && t[i].type == 'checkbox') {
           var a = t[i].name.substring(t[i].name.indexOf('[')+1,t[i].name.indexOf(']'));
           t1.push(a);
           t2.push(t[i].value);
       }
    }
    var str = '';
    for(var i=0;i<t1.length;i++) {
    	str += t1[i]+':'+t2[i]+';';       //按这种格式传给php文件进行分解
    }
	if(n.value == '') {
 		n.value = 1;
	}
	ajax({
	    'url':'?a=cart&m=addProduct',
        'async':false,
        'method':'post',
        'data':{
            'id':id.value,
            'name':name.value,
            'sn':sn.value,
            'price_sale':price_sale.value,
            'num':n.value,
            'prev':prev.value,
            'attr':str,
            'nav':nav.value,
            'weight':weight.value,
            'thumbnail_small':thumbnail_small.value
        },
        'success':function(text) {
            if(text == 1) {
               tips.style.display = 'block';
            } else if(text.indexOf('登陆会员')) {
            	location.href = '?a=member&m=login';
            }
        }	
	});
	return false;
}

function setClose() {
	var tips = document.getElementById('tips');
	tips.style.display = 'none';
}

//改变导航
function channel(j) {
    for(var i=1;i<5;i++) {
        document.getElementById('bn'+i).style.backgroundPosition = 'right';
        document.getElementById('bn'+i).style.color = '#333';
        document.getElementById('c'+i).style.display = 'none';      
    }
    document.getElementById('bn'+j).style.backgroundPosition = 'left';
    document.getElementById('bn'+j).style.color = '#fff';
    document.getElementById('c'+j).style.display = 'block';  
}









